/*
 * @Title QuartzCronTrigger.java
 * @Description
 * @Copyright Copyright(c) 2018
 * @Company com.lizhen
 * @author lizhen
 * @version 0.0.1
 */
package com.lizhen.core;

import org.quartz.*;
import org.quartz.impl.StdSchedulerFactory;

/**
 * @author lizhen
 */
class QuartzCronTrigger {
    public static void main(String[] args) {
        // Quartz 1.6.3
        // JobDetail job = new JobDetail();
        // job.setName("dummyJobName");
        // job.setJobClass(HelloJob.class);
        JobDetail job = JobBuilder.newJob(HelloJob.class).withIdentity("dummyJobName", "group1").build();
        // Quartz 1.6.3
        // CronTrigger trigger = new CronTrigger();
        // trigger.setName("dummyTriggerName");
        // trigger.setCronExpression("0/5 * * * * ?");
        Trigger trigger = TriggerBuilder.newTrigger().withIdentity("dummyTriggerName", "group1")
                .withSchedule(CronScheduleBuilder.cronSchedule("0/2 * * * * ?")).build();
        try {
            Scheduler scheduler = new StdSchedulerFactory().getScheduler();
            scheduler.start();
            scheduler.scheduleJob(job, trigger);
        } catch (SchedulerException e) {
            e.printStackTrace();
        }
    }
}